#import <UIKit/UIKit.h>
#import <AddressBook/AddressBook.h>
#import <AddressBookUI/AddressBookUI.h>
#import <MessageUI/MessageUI.h>
#import "DirectoryCacheOperation.h"
#import "SFUConstants.h"
#import "GraphicsUtilities.h"
#import "ParsingUtilities.h"
#import "MapBuildingSearchDelegate.h"
#import "BusDirectoryDelegate.h"
#import "ReachabilityDelegate.h"

/**
 * A BusDirectoryManager is an object representing the complete
 * management of business directory functionality.
 *
 * A MapBuildingSearchDelegate must be set to respond to requests
 * to view an office location on the map.
 *
 * A BusDirectoryDelegate must be set to respond to events from
 * within the BusDirectoryManager.
 *
 * @author      James Lin
 * @version     2.3.1
 * @since       1.0.7
 * @see         ABUnknownPersonViewControllerDelegate
 * @see         UIAlertViewDelegate
 * @see         MapBuildingSearchDelegate
 * @see         BusDirectoryDelegate
 * @see         MFMailComposeViewControllerDelegate
 * @see         MFMessageComposeViewControllerDelegate
 */
@interface BusDirectoryManager : UITableViewController <ABUnknownPersonViewControllerDelegate, 
														UIAlertViewDelegate, 
														MapBuildingSearchDelegate, 
														MFMailComposeViewControllerDelegate,
														MFMessageComposeViewControllerDelegate> {
	id<MapBuildingSearchDelegate>  buildingDelegate;     // Delegate handling building search request
	id<BusDirectoryDelegate>       directoryDelegate;    // Delegate handling business directory events
	id<ReachabilityDelegate>       reachabilityDelegate; // Delegate for reachability status
	UINavigationController*        parentNav;            // Navigation controller of parent view
	ABUnknownPersonViewController* contactView;          // Viewer for details of a single contact
	NSArray*                       contacts;             // Datasource of contacts
	NSArray*                       indices;              // Indices of the sections in the directory
}

@property (nonatomic, retain) NSArray* contacts;
@property (nonatomic, retain) NSArray* indices;

/**
 * Retrieve the shared instance of the business directory manager.
 *
 * @return  the shared instance of BusDirectoryManager
 */
+ (BusDirectoryManager*)sharedBusDirectoryManager;

/**
 * Display the directory address book in a new view.
 *
 * Pushes this view onto the navigation controller stack of the parent
 * view. Upon tapping the back button, the view is automatically 
 * popped off the top of the navigation stack.
 *
 * @param navController  the navigation controller of the parent view
 * @param theDelegate    delegate handling building search requests
 */
- (void)displayWithNavController:(UINavigationController*)navController 
						delegate:(id<MapBuildingSearchDelegate>)theDelegate;

/**
 * Empty the directory.
 */
- (void)clearDirectory;

/**
 * Set the delegate supplying internet connectivity status.
 *
 * @param delegate  the delegate supplying internet connectiviity status
 * @see             ReachabilityDelegate
 */
- (void)setReachabilityDelegate:(id<ReachabilityDelegate>)delegate;

/**
 * Set the directory event delegate.
 *
 * @param theDelegate  the delegate handling directory events
 */
- (void)setDirectoryDelegate:(id<BusDirectoryDelegate>)theDelegate;

/**
 * Update the directory of contacts with a fresh set of data.
 */
- (void)updateDirectory;

@end
